function parseURL(url) {
	var a = new URL(url);
	console.log(111, a);
	/**
     * URL {
        href: 'https://www.baidu.com:8080/pages/qrcode.html?a=xxx&b=yyy&c=nnn#d=ddd',
        origin: 'https://www.baidu.com:8080',
        protocol: 'https:',
        username: '',
        password: '',
        host: 'www.baidu.com:8080',
        hostname: 'www.baidu.com',
        port: '8080',
        pathname: '/pages/qrcode.html',
        search: '?a=xxx&b=yyy&c=nnn',
        searchParams: URLSearchParams { 'a' => 'xxx', 'b' => 'yyy', 'c' => 'nnn' },
        hash: '#d=ddd'
        }
     */
	return {
		href: url, // 源 url
		protocol: a.protocol.replace(':', ''), // 协议
		host: a.host, // 主机
		hostname: a.hostname, // 主机
		port: a.port, // 端口
		query: a.search, // 参数集合
		params: (function () {
			var params = {},
				seg = a.search.replace(/^\?/, '').split('&'),
				len = seg.length,
				p;
			for (var i = 0; i < len; i++) {
				if (seg[i]) {
					p = seg[i].split('=');
					params[p[0]] = p[1];
				}
			}
			return params;
		})(),
		hash: a.hash.replace('#', ''),
		path: a.pathname.replace(/^([^\/])/, '/$1'),
	};
}

console.log(parseURL('https://www.baidu.com:8080/pages/qrcode.html?a=xxx&b=yyy&c=nnn#d=ddd'));

function test() {
	let newStr = '?a=xxx&b=yyy&c=nnn';
	let args = newStr.replace('?', '').split('&');
	let newMap = {};
	let p;
	for (let i = 0; i < args.length; i++) {
		if (args[i]) {
			p = args[i].split('=');
			newMap[p[0]] = p[1];
		}
	}
	return newMap;
}
console.log(test());
